<%@ page language = "java" contentType="text/html; charset=UTF-8" %>
<%@ page import="com.mapinfo.mapj.*" %>
<%@ page import="com.creawor.imei.base.*" %>
<%@ page import="java.util.*" %>

<%

	
	String hall=request.getParameter("hall");
	if (hall==null) hall=(String)request.getSession().getAttribute("hall");
	

	Common_qry_QueryMap query_map0 = new Common_qry_QueryMap();

	if (hall!=null) 
	{
	 session.setAttribute("hall",hall);
	 
     String sql="select * from v_service_hall where service_hall_code ='"+hall+"'";
     java.util.ArrayList sl = query_map0.findAll_sql(sql,10);
     
     //System.out.println(">>>>>>>>>>>>>>>");
   
	 //System.out.println(query_map0.totalrow);
	
     Iterator it=sl.iterator();
   
     while (it.hasNext())
	 {
      HashMap hm=(HashMap)it.next();
        session.setAttribute("hall_name",(String)hm.get("service_hall_name" ));
        session.setAttribute("area",(String)hm.get("county_code" ));
      }
	}
	else{
	    session.setAttribute("hall",null);
	    session.setAttribute("hall_name",null);
	}
%>
<%




	String area=request.getParameter("area");
	if(area==null) area=(String)request.getSession().getAttribute("area");
	

    //area=(String)request.getSession().getAttribute("area");
  if(area==null) {
     area="HZ";
     session.setAttribute("area","HZ");
	 session.setAttribute("area_name","韶关");
  }
  else
  {
     Common_qry_QueryMap query_map = new Common_qry_QueryMap();

     String sql="select * from t_area where area_code ='"+area+"'";
     java.util.ArrayList sl = query_map.findAll_sql(sql);
     Iterator it=sl.iterator();
     while (it.hasNext())
	 {
      HashMap hm=(HashMap)it.next();
   
     
      session.setAttribute("area",area);
      session.setAttribute("area_name",(String)hm.get("area_name" ));
     }
   }





%>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
	<%@ include file="googlemap_include.jsp"%>
    <script type="text/javascript">

function TextualZoomControl() {
    }
    TextualZoomControl.prototype = new GControl();


    TextualZoomControl.prototype.initialize = function(map) {
      var container = document.createElement("div");

      var zoomInDiv = document.createElement("div");
	  //zoomInDiv.style.font="small Arial 1em";

      this.setButtonStyle_(zoomInDiv);
      container.appendChild(zoomInDiv);
      zoomInDiv.appendChild(document.createTextNode("地图"));
      GEvent.addDomListener(zoomInDiv, "click", function() {
	 	map.setMapType(G_NORMAL_MAP);
        
      });

      var zoomOutDiv = document.createElement("div");
      this.setButtonStyle_(zoomOutDiv);
      container.appendChild(zoomOutDiv);
      zoomOutDiv.appendChild(document.createTextNode("地形地图"));
      GEvent.addDomListener(zoomOutDiv, "click", function() {
	  	map.setMapType(G_PHYSICAL_MAP);
        
      });

      map.getContainer().appendChild(container);
      return container;
    }

    TextualZoomControl.prototype.getDefaultPosition = function() {
      return new GControlPosition(G_ANCHOR_TOP_RIGHT, new GSize(7, 7));
    }

    TextualZoomControl.prototype.setButtonStyle_ = function(button) {
      button.style.textDecoration = "underline";
      button.style.color = "#0000cc";
      button.style.backgroundColor = "white";
      button.style.font = "small-caps   9pt   serif";
	 
      button.style.border = "1px solid black";
      button.style.padding = "2px";
      button.style.marginBottom = "3px";
      button.style.textAlign = "center";
      button.style.width = "5em";
      button.style.cursor = "pointer";
    }

	
	var map = null;
    var geocoder = null;
	var baseIcon=null;
    function initialize() {
      if (GBrowserIsCompatible()) {
	  
         map = new GMap2(document.getElementById("map_canvas"));
		map.addControl(new GSmallMapControl());
		map.addControl(new GMapTypeControl()); 
		map.addControl(new GOverviewMapControl());
     	map.enableDoubleClickZoom();
     	map.enableScrollWheelZoom();
     	map.enableContinuousZoom(); //
		map.setMapType(G_PHYSICAL_MAP);
		//shao guan is (24.996016,113.59314).
        //map.setCenter(new GLatLng(24.816498,113.597088), 14);
		//huizhou is (22.87965466225453,114.5438003540039)
		map.setCenter(new GLatLng(22.87965466225453,114.5438003540039), 10);
		map.addControl(new TextualZoomControl());

		baseIcon = new GIcon();
        baseIcon.shadow = "http://www.google.com/mapfiles/shadow50.png";
        baseIcon.iconSize = new GSize(20, 24);
        baseIcon.shadowSize = new GSize(37, 34);
        baseIcon.iconAnchor = new GPoint(9, 34);
        baseIcon.infoWindowAnchor = new GPoint(9, 2);
        baseIcon.infoShadowAnchor = new GPoint(18, 25);
		
		var point =null;
<%
Common_qry_QueryMap query_map = new Common_qry_QueryMap();
//get datas from v_area_transfer_tele
String sql = "select * from v_area_transfer_tele";
ArrayList list = query_map0.findAll(sql);
System.out.println(list.size());
Iterator it=list.iterator();
while (it.hasNext())
{
	Map map=(HashMap)it.next();
	String x = (String)map.get("x");
	String y = (String)map.get("y");
	if(x==null||y==null||"".equals(x)||"".equals(y))
	{
		continue;
	}
	out.print("point = new GLatLng("+map.get("y")+","+map.get("x")+");");
	out.print("baseIcon.iconSize = new GSize(20, 20);");
	//out.print("map.addOverlay(createMarker(point,'tele.png','test'));");
	out.print("map.addOverlay(createMarker(point,baseIcon,'"+"tele.png',''));");
}

sql="select * from v_area_transfer_un";
list = query_map0.findAll(sql);
System.out.println(list.size());
it=list.iterator();
while (it.hasNext())
{
	Map map=(HashMap)it.next();
	String x = (String)map.get("x");
	String y = (String)map.get("y");
	if(x==null||y==null||"".equals(x)||"".equals(y))
	{
		continue;
	}
	out.print("point = new GLatLng("+map.get("y")+","+map.get("x")+");");
	out.print("baseIcon.iconSize = new GSize(20, 20);");
	//out.print("map.addOverlay(createMarker(point,'tele.png','test'));");
	out.print("map.addOverlay(createMarker(point,baseIcon,'"+"un.png',''));");
}

sql="select * from v_area_transfer_cm";
list = query_map0.findAll(sql);
it=list.iterator();
while (it.hasNext())
{
	Map map=(HashMap)it.next();
	String x = (String)map.get("x");
	String y = (String)map.get("y");
	if(x==null||y==null||"".equals(x)||"".equals(y))
	{
		continue;
	}
	out.print("point = new GLatLng("+map.get("y")+","+map.get("x")+");");
	out.print("baseIcon.iconSize = new GSize(20, 20);");
	//out.print("map.addOverlay(createMarker(point,'tele.png','test'));");
	out.print("map.addOverlay(createMarker(point,baseIcon,'"+"cm.png',''));");
}

%>
		
		  }
    }
	
	function createMarker(point, imageName,html) {
          
          var letteredIcon = new GIcon(baseIcon);
          letteredIcon.image = "http://www.bipub.org/images/GoogleMapsIcons/"+imageName;
		  
		 
      	  markerOptions = { icon:letteredIcon };
          var marker = new GMarker(point, markerOptions);
		  
          GEvent.addListener(marker, "click", function() {
            marker.openInfoWindowHtml("指标 <b>" + html + "</b>");
          });
          return marker;
        }
		
		function createMarker(point, newIcon ,imageName,html) {
          
          var letteredIcon = new GIcon(newIcon);
          letteredIcon.image = "http://www.bipub.org/images/GoogleMapsIcons/"+imageName;
		  markerOptions = { icon:letteredIcon };
          var marker = new GMarker(point, markerOptions);
   		  
          GEvent.addListener(marker, "click", function() {
            marker.openInfoWindowHtml("指标  <b>" + html + "</b>");
          });
          return marker;
        }
</script>
<meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
<title>Google Map</title>






<base target="_self">
<link rel="StyleSheet" href="./css/table.css" type="text/css" />

</head>
<body bgcolor="#DFFFDF" link="#000000" vlink="#000000" alink="#000000" scroll='auto'  onLoad="initialize()" onUnload="GUnload()">    











<form action="show_hint.jsp" name='areaform' id='areaform' methold='post' target='_self'>
<input type="hidden"  name="area" id="area" value="<%=area%>">
<input type="hidden"  name="hall" id="hall"  >
</form>
<%@ include file="googlemap_include2.jsp"%>    
<script>
top.stateFrame.location.href='show_legend_kpi.jsp?kpi_code=transfer';
</script>
</body>




</html>